package com.kzd.gtgame.callback

import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ConvertUtils

class AnimationOnScrollListener : RecyclerView.OnScrollListener() {

    private var totalDy: Int = 0

    private var listener: OnAnimationScrollChangeListener? = null

    fun setOnAnimationScrollListener(listener: OnAnimationScrollChangeListener?) {
        this.listener = listener
    }

    override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
        super.onScrolled(recyclerView, dx, dy)
        totalDy -= dy * -1
        if (totalDy < ConvertUtils.dp2px(300f)) {
            listener?.onScrollChanged(totalDy)
        }
    }

    interface OnAnimationScrollChangeListener {
        fun onScrollChanged(dy: Int)
    }

}